<?php


class MError extends MSingleton {

    private $_errors;
    const EOL = "\n";
    const TAB = "\t";
    
    public function  __construct() {
        $this->_errors = array();
    }


    public function hasErrors() {
        if( !empty($this->_errors )) {
            return true;
        } else {
            return false;
        }
    }

    public function addError($error){
        array_push($this->_errors, $error);
    }

    public function getErrors(){
        return $this->_errors;
    }

    public function renderErrors(){
        $return = '';
        if (!empty($this->_errors)){
            $return .= self::TAB.'<ul>'.self::EOL;
            foreach ($this->_errors as $error){
                $return .= self::TAB.'<li>'.$error.'</li>'.self::EOL;
            }
            $return .= self::TAB.'</ul>'.self::EOL;
            $return .= '</div>'.self::EOL;
        }
        return $return;
    }


}

?>
